function redirectToLogin(userStore, nextState, replace) {
    const user = userStore && userStore.info;
    const { pathname } = nextState.location;
    const noauthReg = /^\/(login)/i;

    // if (!user && !noauthReg.test(pathname)) {
    // 	replace('/login')
    // } else if (user && noauthReg.test(pathname)) {
    // 	replace('/mycar')
    // }
}

function init({ userStore }) {
    return function(nextState, replace) {

        redirectToLogin(userStore, nextState, replace)
    }
}

function onChange(prevState, nextState, replace) {
    G.referrer = prevState.location;

    if (process.env.ENV === 'browser') {
        // 统计
        monitor.getTrack();
        window._czc && _czc.push(["_trackPageview", G.history.createHref(nextState.location),
            `${location.protocol}//${location.host}${G.history.createHref(G.referrer)}`
        ]);
    }
}

export default (context) => ({
    path: '/',
    onEnter: init(context),
    onChange,
    component: require('./components/App').default,
    indexRoute: {
        //  onEnter: (nextState, replace) => replace('/'),
         component:require('./components/Login').default
         },
    childRoutes: [
		require('./routes/Detail'),
        // require('./routes/Getpoint'),
        // require('./routes/Pointrecord'),
        // require('./routes/Rule'),
        // require('./routes/Drawlottery'),
        // require('./routes/Myorder'),
        // require('./routes/Success'),
        // require('./routes/Getprize'),
        // require('./routes/AddressAdd'),
        require('./routes/Adminlet')
    ]
})